<template>
	<view>
		<uni-popup ref="popup" type="bottom">
			<view class="bg-white ">
				<uni-section title="报名审批处理" type="circle">
					<template v-slot:right>
						<view @click="close">关闭</view>
					</template>
				</uni-section>
				<view class="padding-bottom-lg padding-sm" style="padding-bottom: 120rpx;">
					<uni-row :gutter="20" class="font-13">
						<uni-col :span="12"
							class=" margin-bottom-xs">姓名:{{data.vipContractModel.customer.student.name}}</uni-col>
						<uni-col :span="12"
							class=" margin-bottom-xs">号码:{{data.vipContractModel.customer.parentsInfo.phone}}</uni-col>
						<uni-col :span="16"
							class=" margin-bottom-xs">课包名称:{{ data.vipContractModel.curriculumTitle }}</uni-col>
						<uni-col :span="8"
							class=" margin-bottom-xs">类型:{{ data.vipContractModel.typeBx == 0 ? '新签' : data.vipContractModel.typeBx == 1 ? '续费' : '未知' }}</uni-col>
						<uni-col :span="8"
							class=" margin-bottom-xs">课包:{{ data.vipContractModel.curriculumNumber2 }}</uni-col>
						<uni-col :span="8"
							class=" margin-bottom-xs">赠课:{{ data.vipContractModel.numberComplimentaryCourses }}</uni-col>
						<uni-col :span="8"
							class=" margin-bottom-xs">课包价格:{{ data.vipContractModel.curriculumPrice }}</uni-col>
						<uni-col :span="8"
							class=" margin-bottom-xs">付款类型:{{data.vipContractModel.radio==1?'全款':'定金'}}</uni-col>
						<uni-col :span="8"
							class=" margin-bottom-xs">优惠金额:{{ data.vipContractModel.discountPrice }}</uni-col>
						<uni-col :span="8" class=" margin-bottom-xs">付款金额:{{ data.vipContractModel.price }}</uni-col>



					</uni-row>


					<view v-for="item in list" class="card radius padding-sm margin-sm"
						:style="{backgroundColor:item.color ,color:'#fff'}">
						<view style="display: flex;  justify-content: space-between;">
							<view style="font-size: 32rpx;font-weight: bold;">
								{{item.handleStatus ==0?'待'+item.roleName+'处理':item.handleStatus ==1?item.roleName+'拒绝':item.roleName+'同意'}}
							</view>
							<view class="font-13" v-if="item.handleStatus !=0">用户:{{ item.userName }}</view>
						</view>
						<view style="display: flex;  justify-content: space-between;margin-top: 20rpx;"
							v-if="item.handleStatus !=0">
							<view class="font-13">理由:{{ item.remarks }}</view>
							<view class="font-13">时间:{{ item.handleTime }}</view>
						</view>
					</view>






					<view style="display: flex;margin-top: 40rpx;" c>
						<button @click="submitForm(1)" class="login-btn cu-btn block bg-red lg round"
							style="width: 250rpx;margin-right: 20rpx;">拒绝</button>
						<button @click="submitForm(2)" class="login-btn cu-btn block bg-green lg round"
							style="flex: 1;">同意</button>
					</view>

				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		getById
	} from "@/api/vip/contract/VipContractManagementApi";

	import {
		doUpdateHandle
	} from "@/api/approval/record/ApprovalRecordManagementApi";
	import {
		isNull
	} from "@/utils/validate";

	import common from "@/utils/common";

	import {
		formatTime
	} from '@/utils/validate'
	export default {
		data() {
			return {
				queryForm: {
					pageNo: 1,
					pageSize: 10,
					createTime_ORDER: "DESC",
					approvalRecordId_EQ: ""
				},

				form: {
					izUsable: '1',
					approvalRecordId: '',
					handleStatus: '0',
					remarks: ''
				},
				data: {
					vipContractModel: {
						customer: {
							student: {},
							parentsInfo: {}
						}
					}
				},
				list: []
			}
		},
		props: {

		},
		methods: {
			async open(data) {
				this.queryForm.approvalRecordId_EQ = data.id;
				this.form.approvalRecordId = data.id
				this.data = data
				await this.getdata()
				this.$refs.popup.open()
			},
			async submitForm(handleStatus) {
				this.form.handleStatus = handleStatus
				// 处理数据
				const {
					success,
					msg
				} = await doUpdateHandle(this.form);
				if (success) {
					this.close();
				}

			},

			async getdata() {

				const {
					success,
					msg,
					data
				} = await getById(this.queryForm);
				if (success) {



					for (let a in data) {

						if (data[a].handleStatus === 1) {
							data[a].color = '#F56C6C'
						} else if (data[a].handleStatus === 2 || data[a].type === '0') {
							data[a].color = '#67C23A'
						} else {
							data[a].color = '#E6A23C'
						}
					}
					this.list = data
				}

			},

			close() {
				Object.assign(this.$data, this.$options.data());
				this.$refs.popup.close()
				// uni.showTabBar();
				this.$emit('refresh')
			},
		}
	}
</script>

<style lang="scss">
	.card {
		box-shadow: 0px 1px 10px 2px rgba($color: #a5a4a4, $alpha: 0.5);
	}
</style>